package StrategyPattern;

public class InsertionSorter implements Sorter {
    @Override
    public void sort(Comparable[] data) {
        Comparable key;
        int i;
        for (int j = 1; j < data.length; j++) {
            key = data[j];
            i = j - 1;
            while (i >= 0 && data[i].compareTo(key)>0) {
                data[i + 1] = data[i];
                i = i - 1;
            }
            data[i+1]=key;
        }
    }
}
